import { Tooltip } from 'antd';
import styles from './index.less';

export const tableColumns = [
  {
    code: 'statementCode',
    name: '交易类型编码',
    align: 'center',
    width: 80,
    lock: true,
    tooltip: true,
  },
  {
    code: 'statementTypeName',
    name: '结算科目',
    align: 'center',
    width: 100,
    lock: true,
    tooltip: true,
  },
  {
    code: 'transactionAttributesOneName',
    name: '交易属性1(新)',
    align: 'center',
    width: 100,
  },
  {
    code: 'transactionAttributesTwoName',
    name: '交易属性2(新)',
    align: 'center',
    width: 100,
  },
  {
    code: 'transactionAttributesThreeName',
    name: '交易属性3(新)',
    align: 'center',
    width: 100,
  },
  {
    code: 'transactionAttributesFourName',
    name: '交易属性4(新)',
    align: 'center',
    width: 100,
  },
  {
    code: 'dataTypeName',
    name: '数据类型',
    align: 'center',
    width: 100,
  },
  {
    code: 'remark',
    name: '备注',
    align: 'center',
    width: 180,
    tooltip: true,
  },
];

export const tabTableDataSource = {
  code: 'dataSourceFlag',
  name: '-',
  align: 'center',
  width: 140,
  tooltip: true,
  // lock: true,
};

// 日志

export const tabTableColumns = [
  {
    code: 'marketName',
    name: '交易中心',
    align: 'center',
    width: 80,
    tooltip: true,
    // lock: true,
  },
  {
    code: 'statementCode',
    name: '交易类型编码',
    align: 'center',
    width: 80,
    tooltip: true,
    // lock: true,
  },
  {
    code: 'statementTypeName',
    name: '结算科目',
    align: 'center',
    width: 80,
    tooltip: true,
    // lock: true,
  },
  {
    code: 'transactionAttributesOneName',
    name: '交易属性1(新)',
    align: 'center',
    width: 100,
    tooltip: true,
    // lock: true,
  },
  {
    code: 'transactionAttributesTwoName',
    name: '交易属性2(新)',
    align: 'center',
    width: 100,
  },
  {
    code: 'transactionAttributesThreeName',
    name: '交易属性3(新)',
    align: 'center',
    width: 100,
  },
  {
    code: 'transactionAttributesFourName',
    name: '交易属性4(新)',
    align: 'center',
    width: 100,
  },
  {
    code: 'dataTypeName',
    name: '数据类型',
    align: 'center',
    width: 100,
  },
  {
    code: 'remark',
    name: '备注',
    align: 'center',
    width: 180,
    tooltip: true,
  },
];

export const getColumns = ({ edit, del }) => {
  const newTableColumns = [];
  tableColumns.forEach((col) => {
    if (!_.isFunction(col.render)) {
      col.render = (value) => {
        const str = value || value === 0 ? value : value === undefined ? '' : '-';
        return col.tooltip && value ? (
          <Tooltip placement="top" title={str}>
            <div className={styles.textover}>{str}</div>
          </Tooltip>
        ) : (
          str
        );
      };
    }
    newTableColumns.push(col);
  });
  newTableColumns.push({
    name: '操作',
    code: 'operate',
    align: 'center',
    lock: true,
    width: 120,
    render: (value, record, rowIndex) => {
      return !record.id || record.id < 0 ? (
        ''
      ) : (
        <div style={{ display: 'flex', justifyContent: 'center' }}>
          <span
            key="delect"
            style={{
              borderRight: '1px solid var(--font-a30)',
              paddingRight: '10px',
              height: '14px',
              display: 'flex',
              alignItems: 'center',
              color: 'var(--ant-cus-primary_color)',
              cursor: 'pointer',
            }}
            onClick={() => del(record, rowIndex)}
          >
            删除
          </span>
          <span
            key="edit"
            style={{
              padding: '0 10px',
              height: '14px',
              display: 'flex',
              alignItems: 'center',
              color: 'var(--ant-cus-primary_color)',
              cursor: 'pointer',
            }}
            onClick={() => edit(record, rowIndex)}
          >
            编辑
          </span>
        </div>
      );
    },
  });
  return newTableColumns;
};
